package com.elepro.shoppingmall.mapper.orders;

import com.elepro.shoppingmall.entity.orders.Order;
import com.elepro.shoppingmall.entity.orders.OrderGoods;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface OrderMapper {

    @Select("select * from my_order where user_id = #{userId}")
    public List<Order> getOrderByUserId(Long userId);

    @Select("select * from goods_orders where order_id = #{orderId}")
    public List<OrderGoods> getOrderGoodsByOrderId(String orderId);

    @Insert("insert into my_order(order_id,user_id,moneys,address,time) values(#{orderId},#{userId},#{moneys},#{address},#{time})")
    @Options(useGeneratedKeys = true,keyColumn = "id")
    public int insertOrder(Order order);

    @Insert("insert into goods_orders(order_id,goods_id,goods_amount) values(#{orderId},#{goodsId},#{goodsAmount})")
    public int insertOrderGoods(OrderGoods orderGoods);
}
